<template>
	<view class="contain">
		<view class="read-list" v-for="(list, idx) in list" :key="idx">
			<view class="read-date">
				<text class="text">{{ list.date }}</text>
			</view>
			<div class="zixun_list">
				<div class="item_wrap row_between" @tap="goToH5(list.zixunList[index].newsUrl)" v-for="(item, index) in list.zixunList" :key="index">
					<div class="col_between content_wrap">
						<span class="title">{{ item.title }}</span>
						<div class="row_between" style="width: 100%; margin-top: 0upx; font-size: 24upx;">
							<span>{{ item.publishDateStr }}</span>
							<span>{{ item.viewCount }}阅读</span>
						</div>
					</div>
					<image :src="item.picUrl" mode="aspectFill" class="image"></image>
					<image src="../../../static/img/default_icon.png" mode="aspectFill" class="default_image"></image>
				</div>
			</div>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [
				{
					date: '今天',
					zixunList: [
						{
							newsUrl: 'http://www.91fld.com/news/financial/611.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhahtcgvasiimok61i5s7s38.jpg',
							publishDateStr: '今天',
							publishLong: 1569318306000,
							title: '最新！珠海警方通报“新玉猫国际”平台涉非法集资遭立案',
							viewCount: 2
						},
						{
							newsUrl: 'http://www.91fld.com/news/financial/610.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhae34q1uvkg7ikp61qqcee18.jpg',
							publishDateStr: '今天',
							publishLong: 1569318180000,
							title: '百行征信回应：与各股东方保持良好合作关系',
							viewCount: 3
						},
						{
							newsUrl: 'http://www.91fld.com/news/fund/609.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlha9tah10h11n70ihg18nai8j8.jpg',
							publishDateStr: '今天',
							publishLong: 1569318043000,
							title: '公募规模逼近14万亿 这两类基金又火了',
							viewCount: 1
						}
					]
				},
				{
					date: '10月9日',
					zixunList: [
						{
							newsUrl: 'http://www.91fld.com/news/financial/611.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhahtcgvasiimok61i5s7s38.jpg',
							publishDateStr: '2天前',
							publishLong: 1569318306000,
							title: '最新！珠海警方通报“新玉猫国际”平台涉非法集资遭立案',
							viewCount: 2
						},
						{
							newsUrl: 'http://www.91fld.com/news/financial/610.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhae34q1uvkg7ikp61qqcee18.jpg',
							publishDateStr: '2天前',
							publishLong: 1569318180000,
							title: '百行征信回应：与各股东方保持良好合作关系',
							viewCount: 3
						},
						{
							newsUrl: 'http://www.91fld.com/news/fund/609.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlha9tah10h11n70ihg18nai8j8.jpg',
							publishDateStr: '2天前',
							publishLong: 1569318043000,
							title: '公募规模逼近14万亿 这两类基金又火了',
							viewCount: 1
						}
					]
				},
				{
					date: '10月8日',
					zixunList: [
						{
							newsUrl: 'http://www.91fld.com/news/fund/608.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgs5904hae13lo1hrgr13sg58.jpg',
							publishDateStr: '3天前',
							publishLong: 1569303211000,
							title: '超30%百亿私募以逾八成仓位运作 估值修复行情将继续',
							viewCount: 1
						},
						{
							newsUrl: 'http://www.91fld.com/news/financial/607.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgrudk21h78147ajq1nl51d958.jpg',
							publishDateStr: '3天前',
							publishLong: 1569302987000,
							title: '基金齐声唱多:黄金上涨仍在路上',
							viewCount: 3
						},
						{
							newsUrl: 'http://www.91fld.com/news/macro/606.html',
							picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgmdp8i2kn1pokmt9mv170u8.jpg',
							publishDateStr: '3天前',
							publishLong: 1569297198000,
							title: '中国要不要降息？刚刚，易纲回应了',
							viewCount: 5
						}
					]
				}
			]
		};
	},
	methods: {
		goToH5: function(url) {
			if (this.getUrlQueryString(url, 'needlogin') == 1) {
				// 需要登录
				let auth_token = uni.getStorageSync('auth_token');
				if (auth_token) {
					// 可以登录
					if (this.getUrlQueryString(url, 'hidehead') == 1) {
						// 需要隐藏头
						uni.setStorageSync('couponUrl', url);
						console.log(url);
						uni.navigateTo({
							url: '/pages/tixian_webview/tixian_webview?url=' + url
						});
					} else {
						uni.navigateTo({
							url: '/pages/home_webview/home_webview?url=' + url
						});
					}
				} else {
					uni.navigateTo({
						url: '/pages/get_code/get_code'
					});
				}
			} else {
				// 不需要登录
				if (this.getUrlQueryString(url, 'hidehead') == 1) {
					// 需要隐藏头
					uni.setStorageSync('couponUrl', url);
					console.log(url);
					uni.navigateTo({
						url: '/pages/tixian_webview/tixian_webview?url=' + url
					});
				} else {
					uni.navigateTo({
						url: '/pages/home_webview/home_webview?url=' + url
					});
				}
			}
		},
		getUrlQueryString(url, name) {
			var reg = new RegExp('[?&]' + name + '=([^&#]*)', 'i');
			var res = url.match(reg);

			if (res && res.length > 1) {
				return decodeURIComponent(res[1]);
			}
			return '';
		}
	}
};
</script>

<style lang="scss">
.read-date {
	height: 70upx;
	background: #f5f5f5;
	line-height: 70upx;
	.text {
		color: #999999;
		font-size: 34upx;
		margin-left: 29upx;
	}
}
.zixun_list {
	margin-bottom: 0upx;
	background: #ffffff;
	padding: 0upx 30upx;
}
.zixun_list .item_wrap {
	height: 180upx;
	width: 100%;
	box-sizing: border-box;
}
.zixun_list .item_wrap .content_wrap {
	height: 140upx;
	flex: 1;
	color: #999999;
	font-size: 16upx;
	line-height: 1;
}
.zixun_list .item_wrap .content_wrap .title {
	color: #303030;
	font-size: 32upx;
	font-weight: bold;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.zixun_list .item_wrap .image {
	height: 130upx;
	width: 180upx;
	position: relative;
	z-index: 2;
	margin-left: 27upx;
	min-height: 130upx;
	min-width: 180upx;
}
.zixun_list .item_wrap .default_image {
	height: 130upx;
	width: 180upx;
	position: absolute;
	right: 0upx;
	margin-left: 27upx;
	min-height: 130upx;
	min-width: 180upx;
	position: absolute;
	right: 30upx;
}
.btn {
	height: 94upx;
	line-height: 94upx;
	width: 236upx;
	background: #ffca0a;
	border-radius: 12upx;
	text-align: center;
	color: #303030;
	font-size: 36upx;
	margin-top: 70upx;
	font-weight: bold;
}
</style>
